/********************************************************************
	created:	2010/03/09
	created:	9:3:2010   20:35
	filename: 	Download_i.h
	author:		wpan
	
	purpose:	
*********************************************************************/

#pragma once
#include <string>
typedef enum emDownCoustomError
{
	DOWNLOAD_SUCCESS = 1,
	DOWNLOAD_CONNTCTED_FAILED = 2,
	DOWNLOAD_SERVER_RESPONSE_FAILED,
	DOWNLOAD_SERVER_CLOSE,
	DOWNLOAD_TIMEOUT,
	DOWNLOAD_PROGRESSS,
	DOWNLOAD_WRITE_FIALED,
	DOWNLOAD_RENAME_FILE,	
}DownCoustomError;

struct XmlData
{
	std::wstring srcName;
	std::wstring dstName;
	double version;
};
struct FileData
{
	std::wstring srcName;
	std::wstring dstName;
	// 	size_t version;
	// 	bool isDelete;
};





class IDownloadEvent
{	
public:
	virtual void OnDownloadFailed(DWORD error) = 0;
	virtual void OnDownloadSuccessed(int nOK) = 0;
};

class IDownload
{
public:
	virtual void setEventHandler(IDownloadEvent* pEventHandler) = 0;
	//virtual void RemoveEventHandler(IDownloadEvent* pEventHandler) = 0;
	//virtual void InsertFile(const int& idx, const FileData&  tgFile) = 0;
	//virtual void GetConfigsCountOfOneDistrict(const int& idx) = 0;
	//virtual bool DownloadFiles(int idx, bool bForceUpdate) = 0;
};

typedef long DownLoadTaskID;

#define INVALID_DOWNLOAD_TASK_ID -1;


typedef struct tgDownloadProcessinfo 
{
	DownLoadTaskID taskID;
	__int64 nProcessed;
	__int64 nTotalSize;
	int nSpeed;
}DownloadProcessinfo;

class IThreadDownloadEvent
{	
public:
	virtual void OnDownloadFailed(DownLoadTaskID task, DWORD error, LPCWSTR sErrorMessage, INT64 nErrorDetail = 0, void* paramdetail = NULL) = 0;
	virtual void OnDownloadSuccessed(DownLoadTaskID task, LPCWSTR sFileName, int nOK) = 0;
	virtual void OnDownloadProgress(DownLoadTaskID taskID, int nProcessed, int nTotalSize, int nSpeed) = 0;	
};



class IThreadDownload
{
public:
	virtual void AddEventHandler(IThreadDownloadEvent* pEventHandler) = 0;
	virtual void RemoveEventHandler(IThreadDownloadEvent* pEventHandler) = 0;
};
